package ru.lukyanets.transmission.client.connection;

import ru.lukyanets.transmission.protocol.client.builder.HostInfo;

/**
 * @author slukyanets
 */
public class ConnectionInfo {
    public static final int DEFAULT_PORT = 9091;
    public static final int DEFAULT_PROXY_PORT = 9091;

    private final String name;
    private HostInfo host;
    private boolean useSsl;
    private HostInfo proxyHost;
    private String alternativePath;

    public ConnectionInfo(String name) {
        this.name = name;
    }

    public ConnectionInfo(ConnectionInfo other) {
        this.name = other.name;
        this.host = other.host != null ? new HostInfo(other.host) : null;
        this.useSsl = other.useSsl;
        this.proxyHost = other.proxyHost != null ? new HostInfo(other.proxyHost) : null;
        this.alternativePath = other.alternativePath;
    }

    public String getName() {
        return name;
    }

    public HostInfo getHost() {
        return host;
    }

    public void setHost(HostInfo host) {
        this.host = host;
    }

    public boolean isUseSsl() {
        return useSsl;
    }

    public void setUseSsl(boolean useSsl) {
        this.useSsl = useSsl;
    }

    public HostInfo getProxyHost() {
        return proxyHost;
    }

    public void setProxyHost(HostInfo proxyHost) {
        this.proxyHost = proxyHost;
    }

    public String getAlternativePath() {
        return alternativePath;
    }

    public void setAlternativePath(String alternativePath) {
        this.alternativePath = alternativePath;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ConnectionInfo that = (ConnectionInfo) o;

        return name.equals(that.name);

    }

    @Override
    public int hashCode() {
        return name.hashCode();
    }
}
